Skip to content

Load large Dropdown choices progressively on scroll - #13805

Open
abidlabs wants to merge 18 commits into
mainfrom
fix/issue-13340-gr-dropdown-with-large-choices-list-is-4-slower-
Open

Load large Dropdown choices progressively on scroll#13805
abidlabs wants to merge 18 commits into
mainfrom
fix/issue-13340-gr-dropdown-with-large-choices-list-is-4-slower-

Conversation

@abidlabs

@abidlabs abidlabs commented Aug 31, 2026

Copy link
Copy Markdown
Member

Description

Large filterable Dropdowns rendered every matching choice, creating tens of thousands of DOM nodes and making opening and filtering slow. This PR adds num_choices_shown (default: 100), which controls the initial number of matching choices rendered and the size of each subsequent batch.

When the user reaches the bottom of the options list, the next batch loads automatically. The compact Dropdown viewport stays consistent while every matching choice remains browsable without a separate “Show more” control. Setting num_choices_shown=None renders all matching choices immediately.

The selected single-select option remains available when it falls beyond the initial batch, and the options list announces the number shown and remaining for assistive technology.

Closes: #13340
Closes: #8396

AI Disclosure

  • I used OpenAI Codex to help address review feedback, implement and visually verify the scroll-loading interaction, and add regression tests.
  • I did not use AI

Testing and Formatting

  • CI=1 pnpm exec vitest run --config .config/vitest.config.ts js/dropdown/dropdown.test.ts (131 passed, 4 todo)
  • python3 -m pytest test/components/test_dropdown.py -q (2 passed)
  • Targeted Prettier and Ruff formatting/checks passed
  • pnpm ts:check reports 16 existing errors outside the Dropdown files

@gradio-pr-bot

gradio-pr-bot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/8459129f5651cec1535665652bdbba094238fd95/gradio-6.26.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@8459129f5651cec1535665652bdbba094238fd95#subdirectory=client/python"

Import Gradio JS Client from this PR via CDN

import { Client } from "https://huggingface.co/buckets/gradio/npm-previews/resolve/8459129f5651cec1535665652bdbba094238fd95/browser.js";

@gradio-pr-bot

gradio-pr-bot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/dropdown minor
gradio minor

  • Load large Dropdown choices progressively on scroll

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs

abidlabs commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Before / after Spaces

Both public Spaces run the same 70,000-choice app.py.

Version Space Rendered options Open time Filter time
Gradio 6.26.0 Before 70,000 4.97 s 1.37 s
PR preview wheel After 100 265 ms 53 ms

The filter text was User_6999; both versions returned the same ten choices (User_69990 through User_69999). The after Space installs the preview wheel built from commit 61f8b19f1abffc64bf3727d332008ba70d68ae87.

@abidlabs
abidlabs requested a lite review from Copilot August 31, 2026 17:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…-large-choices-list-is-4-slower-' into fix/issue-13340-gr-dropdown-with-large-choices-list-is-4-slower-
@abidlabs
abidlabs requested review from dawoodkhan82 and hysts August 31, 2026 17:26
@abidlabs
abidlabs marked this pull request as ready for review August 31, 2026 17:39
@abidlabs
abidlabs requested a balanced review from Copilot September 1, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread js/dropdown/shared/Dropdown.svelte Outdated
Comment on lines 141 to 142
filtered_indices = handle_filter(choices, "", visible_values_limit);
active_index = selected_index;
Comment thread js/dropdown/dropdown.test.ts Outdated
Comment on lines +1046 to +1052
const { container, getAllByTestId } = await render(Dropdown, {
...multiselect_props,
max_values_shown: 2
});

const input = container.querySelector("input") as HTMLInputElement;
await input.focus();
Comment thread js/dropdown/shared/Dropdown.svelte Outdated
container = true,
allow_custom_value = false,
filterable = true,
max_values_shown = 100,
Comment thread js/dropdown/types.ts Outdated
export interface DropdownProps {
multiselect: boolean;
max_choices: number | null;
max_values_shown: number | null;

@dawoodkhan82 dawoodkhan82 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there needs to be a "see more" at the end of the 100 options, to load additional options. As a user, if I don't know what I'm looking for I may need to browse further.

@abidlabs abidlabs changed the title Limit visible Dropdown options for large choice lists Load large Dropdown choices progressively on scroll Sep 1, 2026
@abidlabs

abidlabs commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

Thanks @dawoodkhan82 for the suggestion. Agreed that the previous UI would be misleading. At the same time, I didn't want the user to have to click the "show more" button so instead I added a scroll:

Screen.Recording.2026-09-01.at.3.34.40.PM.mov

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Keyboard users cannot reach unloaded choices, selected-option scrolling regresses, and the hand-authored changeset violates repository guidance.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment on lines +208 to +210
update_filtered_choices(
is_filtering ? input_text : "",
visible_choices_limit
Comment thread js/dropdown/shared/DropdownOptions.svelte Outdated
Comment thread js/dropdown/shared/Multiselect.svelte Outdated
Comment on lines +49 to +52
const result = handle_filter_with_count(
translated_choices,
input_text,
visible_choices_limit
Comment on lines +1 to +6
---
"@gradio/dropdown": minor
"gradio": minor
---

feat:Load large Dropdown choices progressively on scroll

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changeset was generated by gradio-pr-bot (commits f13d293 and a8ef3dc), not hand-authored. Keeping the bot-generated file is consistent with the repository guidance and avoids replacing or fighting the automated changelog entry.

Comment on lines +209 to +210
<span class="sr-only" aria-live="polite">
{filtered_indices.length} choices shown, {remaining_choices} remaining
…-large-choices-list-is-4-slower-' into fix/issue-13340-gr-dropdown-with-large-choices-list-is-4-slower-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gr.Dropdown with large choices list is ~4× slower to render suggestions in 6.13.0 vs 5.30.0 Limit the amount of values shown in a Dropdown element.

4 participants